<template>

	<view class="editPhoto">
		<u-navbar
			title="编辑企业图片"
			:border-bottom="false" 
			:custom-back="goback"
		></u-navbar>
		<view class="editPhoto__area">
<!-- 			<view class="editPhoto__area__prebox" v-if="!store.state.showUploadList">
				<view class="editPhoto__area__prebox__pre-item" v-for="(item, index) in store.state.lists" :key="index">
					<image class="editPhoto__area__prebox__pre-item__image" :src="item.url" mode="aspectFill"></image>
					<view class="editPhoto__area__prebox__pre-item__delete-icon" @click="deleteItem(index)">
						<u-icon name="close" size="20" color="#ffffff"></u-icon>
					</view>
					<u-line-progress v-if="item.progress > 0 && !item.error" :show-percent="false" height="16" class="u-progress"
					 :percent="item.progress"></u-line-progress>
				</view>
			</view> -->
			<u-upload @on-choose-fail="onChooseFail" :before-remove="beforeRemove" ref="uUpload" :custom-btn="customBtn" :show-upload-list="store.state.showUploadList" :auto-upload="autoUpload" :file-list="store.state.lists"
			 :show-progress="showProgress" :deletable="deletable" :max-count="maxCount" @on-list-change="onListChange">
				<view v-if="customBtn" slot="addBtn" class="editPhoto__area__slot-btn" hover-class="editPhoto__area__slot-btn--hover" hover-stay-time="150">
					<u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon>
				</view>
			</u-upload>
		</view>
		
<!-- 		<view class="editPhoto__bottom-box">
			<view class="editPhoto__bottom-box__cancel" @click="cancelModel=true">取消</view>
			<view class="editPhoto__bottom-box__submit" @click="submitModel=true">保存修改</view>
		</view>
		<u-modal v-model="cancelModel"
			:show-title="false"
			content="确认取消"
			:show-cancel-button="true"
			confirm-color="#177fff"
			@confirm="goback">
		</u-modal>
		<u-modal v-model="submitModel" 
			:show-title="false"
			content="确认提交修改吗"
			:show-cancel-button="true"
			confirm-color="#177fff"
			@confirm="submit">
		</u-modal> -->
		
	</view>

	
</template>

<script>
	import store from "./store"
	export default {
		data() {
			return {
				store:store,
				fileList: [],
				// showUploadList: true,
				customBtn: false,
				autoUpload: false,
				showProgress: false,
				deletable: true,
				customStyle: false,
				maxCount: 8,
				// lists: [], // 组件内部的文件列表
			}
		},
		mounted() {
			// this.lists=this.store.state.photoList
			// if(this.lists.length>0){
			// 	this.showUploadList=false
			// }
			console.log("photoListNew",this.store.state.lists)
			console.log("show",this.store.state.showUploadList)

		},
		methods: {
			goback(){
				// this.store.state.photoList=this.lists
				console.log("photoList",this.store.state.photoList)
				uni.navigateBack({
					
				})
			},
			upload() {
				this.$refs.uUpload.upload();
			},
			deleteItem(index) {
				this.$refs.uUpload.remove(index);
			},

			onListChange(lists) {
				// console.log('onListChange', lists);
				this.store.state.lists = lists;
				console.log("showChanse",this.store.state.showUploadList)
			},
			beforeRemove(index, lists) {
				return true;
			},
			onChooseFail(e) {
				// console.log(e);
			}
		}
	}
</script>
<style lang="less">
	.editPhoto{
		display: flex;
		flex-direction: column;
		align-items: center;
		&__title{
			
		}
		&__area{
			// display: flex;
			// flex-direction: column;
			// align-items: flex-start;
			width: 360px;
			&__prebox{
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;
				&__pre-item{
					flex: 0 0 48.5%;
					border-radius: 10rpx;
					// width: 329rpx;
					// height: 140rpx;
					overflow: hidden;
					position: relative;
					margin-bottom: 20rpx;
					&__image{
						// width: 329rpx;
						// height: 140rpx;
					}
					&__delete-icon{
						position: absolute;
						top: 10rpx;
						right: 10rpx;
						z-index: 10;
						background-color: @color-blue;
						border-radius: 100rpx;
						width: 44rpx;
						height: 44rpx;
						display: flex;
						align-items: center;
						justify-content: center;
					}
				}
				
			}
			&__slot-btn{
				width: 329rpx;
				height: 140rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background: rgb(244, 245, 246);
				border-radius: 10rpx;
				&--hover{
					background-color: rgb(235, 236, 238);
				}
			}
		}
		&__bottom-box{
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			position: fixed;
			padding: @uni-spacing-row-lg @uni-spacing-col-lg;
			bottom: 0;
			width: calc(100vw);
			background-color: #fff;
			
			&__cancel{
				margin-right: @uni-spacing-col-lg;
				padding-top: @uni-spacing-row-base;
				padding-bottom: @uni-spacing-row-base;
				text-align: center;
				flex: 0.5;
				border-radius: @uni-border-radius-base;
				border: 1px solid @font-color-blue;
				font-size: @uni-font-size-lg;
				color: @font-color-blue;
			}
			&__submit{
				padding-top: @uni-spacing-row-base;
				padding-bottom: @uni-spacing-row-base;
				text-align: center;
				flex: 1;
				border-radius: @uni-border-radius-base;
				border: 1px solid @font-color-blue;
				background-color: @uni-bg-color-blue;
				font-size: @uni-font-size-lg;
				color: #fff;
			}
		}
	}
</style>

	

